package com.alibaba.nls.client;

import java.io.IOException;

/**
 * @author siwei
 * @date 2019-10-30
 */
public class CreateToken {

    public static void main(String[] args) {
//        if (args.length < 2) {
//            System.err.println("CreateTokenDemo need params: <accessKeyId> <accessKeySecret>");
//            System.exit(-1);
//        }

//        String accessKeyId = args[0];
//        String accessKeySecret = args[1];


        AccessToken accessToken = new CreateToken().requestToken();

        System.out.println("Token: " + accessToken.getToken() + ", expire time: " + accessToken.getExpireTime());

    }


    public AccessToken requestToken() {

        String accessKeyId = "LTAI5tP2yuLXhZXqZKPfgi8C";
        String accessKeySecret = "5btqQxDa41rgvtKGKNr8Mb0p53E6go";
        System.out.println("accessKeyId=" + accessKeyId + "; accessKeySecret=" + accessKeySecret);
        AccessToken accessToken = new AccessToken(accessKeyId, accessKeySecret);
        try {
            accessToken.apply();
            return accessToken;
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }

}
